import request from '@/utils/request'

// 查询参股基金_投资组合列表
export function listBfInvestGroup(query) {
  return request({
    url: '/investGroup/bfInvestGroup/list',
    method: 'get',
    params: query
  })
}
// 查询参股基金_投资组合列表出资穿透
export function listBfInvestGroupName(query) {
  return request({
    url: '/investGroup/bfInvestGroup/listName',
    method: 'get',
    params: query
  })
}

export function listBfInvestGroupNoPage(query) {
  return request({
    url: '/investGroup/bfInvestGroup/list/no/page',
    method: 'get',
    params: query
  })
}
// 查询投资汇总数据
export function getInvestSummary(query) {
  return request({
    url: '/investGroup/bfInvestGroup/map',
    method: 'get',
    params: query
  })
}

// 查询参股基金_投资组合详细
export function getBfInvestGroup(id) {
  return request({
    url: '/investGroup/bfInvestGroup/' + id,
    method: 'get'
  })
}
// 参股基金投后首页-查询投资汇总数据
export function dealInvestGroupTarget(dealId) {
  return request({
    url: '/investGroup/bfInvestGroup/getBfInvestGroupTarget/' + dealId,
    method: 'get'
  })
}
// 查询参股基金_投资组合详细
export function getBfInvestViewData(id) {
  return request({
    url: '/investGroup/bfInvestGroup/getBfInvestViewData/' + id,
    method: 'get'
  })
}

// 根据公司名称模糊匹配公司列表
export function bfInvestGroupListByName(companyName) {
  return request({
    url: '/investGroup/bfInvestGroup/bfInvestGroupListByName?companyName=' + companyName,
    method: 'get'
  })
}

// 根据天眼查ID或者公司名称获取公司工商详情
export function bfInvestGroupDetailsByName(query) {
  return request({
    url: '/investGroup/bfInvestGroup/bfInvestGroupDetailsByName',
    method: 'get',
    params: query
  })
}

// 保存参股基金_投资组合
export function saveBfInvestGroup(data) {
  return request({
    url: '/investGroup/bfInvestGroup/save',
    method: 'post',
    data: data
  })
}

// 删除参股基金_投资组合
export function delBfInvestGroup(id) {
  return request({
    url: '/investGroup/bfInvestGroup/' + id,
    method: 'delete'
  })
}

// 删除关键条款
export function deleteBfInvestGroupInfo(id) {
  return request({
    url: '/investGroup/bfInvestGroup/deleteBfInvestGroup/' + id,
    method: 'delete'
  })
}

// 根据公司ID，获取所有的关键条款
export function lisDealName(query) {
  return request({
    url: '/investGroup/bfInvestGroup/lisDealName',
    method: 'get',
    params: query
  })
}

// 校验流程标识是否重复
export function checkCompanyName(companyName, dealId, indirectDealId) {
  var query = {}
  query.companyName = companyName
  query.dealId = dealId
  query.indirectDealId = indirectDealId
  return request({
    url: '/investGroup/bfInvestGroup/checkCompanyName/',
    method: 'get',
    params: query
  })
    .then(result => result.code === 200 && result.data)
}

export function getInvestGroupByCompanyId(companyId) {
  return request({
    url: '/investGroup/bfInvestGroup/getInvestGroupByCompanyId/' + companyId,
    method: 'get'
  })
}

export function getBfLatestShareholdingRatio(dealId, indirectDealId) {
  return request({
    url: '/investGroup/bfInvestGroup/getBfLatestShareholdingRatio/' + dealId + '/' + indirectDealId,
    method: 'get'
  })
}

// 校验简称重复
export function checkShortName(shortName, dealId) {
  if (shortName === '' || shortName === null || shortName === undefined) {
    shortName = '-999'
  }
  return request({
    url: '/investGroup/bfInvestGroup/checkShortName/' + shortName + '/' + dealId,
    method: 'get'
  })
}

/**
 * 提交检验后的导入数据
 * @param data
 * @returns {*}
 */
export function uploadSubmit(data) {
  return request({
    url: '/investGroup/bfInvestGroup/uploadSubmit',
    method: 'post',
    data: data
  })
}
